/**
 * 登录人员列表
 */
Ext.define('app.view.user.List', {

	extend: 'Ext.grid.Panel',
	
	alias: 'widget.userlist',
	
	requires: [
		'app.view.user.UserController',
		'app.view.user.UserModel',
		'app.view.user.window.UserWindow'
	],
	
	viewModel: {
		type: 'user'
	},
	controller: 'user',
	
	bind: {
		store: '{userStore}'
	},
	
	columns: [
		{text: '序号', xtype: 'rownumberer', width: 50, align: 'center', sortable: false},
		{hidden: true, dataIndex: 'id'},
		{text: '<center>登录名</center>', dataIndex: 'username', width: 120},
		{text: '<center>用户名</center>', dataIndex: 'nickname', width: 120},
		{text: '<center>真实姓名</center>', dataIndex: 'realname', width: 120, renderer: function(val, metaData, model, row, col, store, gridview) {  
                metaData.tdStyle = 'font-weight:bold;';
				return val; 
            }},
		{text: '<center>身份证</center>', dataIndex: 'idcard', width: 150, renderer: function(v, metaData, model, row, col, store, gridview) {
				if (!v) {
        			return "";
        		}
        		return v.substring(0, v.length-4) + "****";
        	}},
		{text: '<center>出生日期</center>', dataIndex: 'birthday', width: 120, align:'center', xtype: 'datecolumn', renderer: function(val, metaData, model, row, col, store, gridview) {
    			metaData.tdStyle = 'color:#a40;';
				return Ext.util.Format.date(val, 'Y-m-d'); 			
    		}},
		{text: '<center>年龄</center>', dataIndex: 'age', width: 60, align:'center'},
		{text: '<center>性别</center>', dataIndex: 'gender', width: 60, align:'center', renderer: function(val, metaData, model, row, col, store, gridview) {
            	metaData.tdStyle = 'color:' + (val == 'M' ? 'red' : 'green') + ';'
				return val == 'M' ? '男' : '女';
        	}},
		{text: '<center>手机号码</center>', dataIndex: 'phoneNumber', width: 120},
		{text: '<center>电子邮箱</center>', dataIndex: 'email', width: 200},
		{text: '<center>家庭住址</center>', dataIndex: 'address', width: 300}
	],
	
	selModel: {
      	selType: 'checkboxmodel',
      	injectCheckbox: 1,
      	ignoreRightMouseSelection: true, //忽略右键选中
      	mode: 'SIMPLE',
      	checkOnly: true //只有在勾选复选框的时候，才选中这一行数据。设置之后，默认采用了单元格选中
  	},
  	loadMask: true,
  	border: true,
  	columnLines: true,
  	rowLines: true,
  	frame: true,
  	emptyText: '没有数据',
	
	tbar: [{
		text: '新增',     
        glyph: 0xf016,
        handler: 'newUser'
    },{    
        text: '修改',    
        glyph: 0xf044,
        itemId: 'modify',
        handler: 'editUser',
        disabled: true
    },{    
        text: '删除',    
        glyph: 0xf014,
        itemId: 'delete',
        handler: 'deleteUser',
        disabled: true
    },{    
        text: '查看',    
        glyph: 0xf022,
        handler: 'viewUser'
	}, '->', {
		xtype: 'textfield',
        name: 'searchkey',
        emptyText: '输入搜索词'		
	}],
	
	dockedItems: [{
		xtype: 'pagingtoolbar',
		dock: 'bottom',
		displayInfo: true,
		bind: {
			store: '{userStore}'
		}
	}],
	
	listeners: {
		selectionchange: 'onSelectionChange'
	}
}) 